package libaryinterface.interfaceutils;

import libaryinterface.login.RegistrationInterface;

import libaryinterface.login.LoginInterface;
import service.UserService;
import service.impl.UserServiceImpl;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

//初始界面
public class PrivateInterface{
    JFrame f1;
    JPanel p1;
    JButton b1,b3;
    JTextField t1;
    UserService userService = new UserServiceImpl();
    public PrivateInterface() {
        f1 = new JFrame("图书馆管理系统");
        p1 = new JPanel();
        b1 = new JButton("注册");
        b3 = new JButton("登陆");
        ImageIcon bg = new ImageIcon("src//picture//ads.png");
        JLabel label = new JLabel(bg);
        label.setSize(bg.getIconWidth(),bg.getIconHeight());
        f1.getLayeredPane().add(label,new Integer(Integer.MIN_VALUE));
        //2.把窗口面板设为内容面板并设为透明、流动布局。
        p1=(JPanel)f1.getContentPane();
        p1.setOpaque(false);
        p1.setLayout((new FlowLayout()));
        p1.setLayout(null);
        b1.setBounds(260, 500, 100, 50);
        b3.setBounds(50, 500, 100, 50);
        b3.setBackground(new Color(16, 140, 8));
        b3.setForeground(Color.white);
        b3.setFont(new Font("思源黑体",Font.PLAIN,20));
        b1.setFont(new Font("思源黑体",Font.PLAIN,20));
        p1.add(b3);
        p1.add(b1);
        f1.setVisible(true);
        f1.setBounds(600, 250, 430, 600);
        //userService = new UserServiceImpl();
        //登录按钮监听器
        b3.addActionListener(new ActionListener() {
            Boolean flag;
            @Override
            public void actionPerformed(ActionEvent e) {
                new LoginInterface();
                f1.dispose();
            }
        });
        //注册按钮监听器
        b1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new RegistrationInterface();
                f1.dispose();
            }
        });
        f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

}